home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 1 / QRZ Ham Radio Callsign Database - December 1993.iso / ucsd / packet / tcpip / amiga / asrc29k.lha / global.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-08  |  5.3 KB  |  195 lines

  1. #ifndef    MAXINT16
  2.  
  3. /* Global definitions used by every source file.
  4.  * Some may be compiler dependent.
  5.  */
  6.  
  7. #if    defined(__TURBOC__) || defined(__STDC__) || defined(LATTICE)
  8. #define    ANSIPROTO    1
  9. #endif
  10.  
  11. #ifndef    __ARGS
  12. #ifdef    ANSIPROTO
  13. #define    __ARGS(x)    x
  14. #else
  15. #define    __ARGS(x)    ()
  16. #endif
  17. #endif
  18.  
  19.  
  20. #if    !defined(AMIGA) && (defined(LATTICE) || defined(MAC) || defined(__TURBOC__))
  21. /* These compilers require special open modes when reading binary files.
  22.  * 
  23.  * "The single most brilliant design decision in all of UNIX was the
  24.  * choice of a SINGLE character as the end-of-line indicator" -- M. O'Dell
  25.  *
  26.  * "Whoever picked the end-of-line conventions for MS-DOS and the Macintosh
  27.  * should be shot!" -- P. Karn's corollary to O'Dells' declaration
  28.  */
  29. #define    READ_BINARY    "rb"
  30. #define    WRITE_BINARY    "wb"
  31. #define    READ_TEXT    "rt"
  32. #define    WRITE_TEXT    "wt"
  33. #define    APPEND_TEXT    "at+"
  34.  
  35. #else
  36.  
  37. #define    READ_BINARY    "r"
  38. #define    WRITE_BINARY    "w"
  39. #define    READ_TEXT    "r"
  40. #define    WRITE_TEXT    "w"
  41. #define    APPEND_TEXT    "a+"
  42.  
  43. #endif
  44.  
  45. /* These two lines assume that your compiler's longs are 32 bits and
  46.  * shorts are 16 bits. It is already assumed that chars are 8 bits,
  47.  * but it doesn't matter if they're signed or unsigned.
  48.  */
  49. typedef long int32;        /* 32-bit signed integer */
  50. typedef unsigned short int16;    /* 16-bit unsigned integer */
  51. #define    uchar(x) ((unsigned char)(x))
  52. #define    MAXINT16 65535        /* Largest 16-bit integer */
  53. #define    MAXINT32 4294967295L    /* Largest 32-bit integer */
  54.  
  55. /* The "interrupt" keyword is non-standard, so make it configurable */
  56. #ifdef    __TURBOC__
  57. #define    INTERRUPT    void interrupt
  58. #else
  59. #define    INTERRUPT    void
  60. #endif
  61.  
  62. /* Note that these definitions are on by default if none of the Turbo-C style
  63.  * memory model definitions are on; this avoids having to change them when
  64.  * porting to 68K environments.
  65.  */
  66. #if    !defined(__TINY__) && !defined(__SMALL__) && !defined(__MEDIUM__)
  67. #define    LARGEDATA    1
  68. #endif
  69.  
  70. #if    !defined(__TINY__) && !defined(__SMALL__) && !defined(__COMPACT__)
  71. #define    LARGECODE    1
  72. #endif
  73.  
  74. /* Since not all compilers support structure assignment, the ASSIGN()
  75.  * macro is used. This controls how it's actually implemented.
  76.  */
  77. #ifdef    NOSTRUCTASSIGN    /* Version for old compilers that don't support it */
  78. #define    ASSIGN(a,b)    memcpy((char *)&(a),(char *)&(b),sizeof(b));
  79. #else            /* Version for compilers that do */
  80. #define    ASSIGN(a,b)    ((a) = (b))
  81. #endif
  82.  
  83. /* Define null object pointer in case stdio.h isn't included */
  84. #ifndef    NULL
  85. /* General purpose NULL pointer */
  86. #define    NULL (void *)0
  87. #endif
  88. #define    NULLCHAR (char *)0    /* Null character pointer */
  89. #define    NULLCHARP (char **)0    /* Null character pointer pointer */
  90. #define    NULLINT    (int *)0    /* Null integer pointer */
  91. #define    NULLFP     (int (*)())0    /* Null pointer to function returning int */
  92. #define    NULLVFP     (void (*)())0    /* Null pointer to function returning void */
  93. #define    NULLVIFP (INTERRUPT (*)())0
  94. #define    NULLFILE (FILE *)0    /* Null file pointer */
  95.  
  96. /* Extract a short from a long */
  97. #define    hiword(x)    ((int16)((x) >> 16))
  98. #define    loword(x)    ((int16)(x))
  99.  
  100. /* Extract a byte from a short */
  101. #define    hibyte(x)    ((unsigned char)((x) >> 8))
  102. #define    lobyte(x)    ((unsigned char)(x))
  103.  
  104. /* Extract nibbles from a byte */
  105. #define    hinibble(x)    (((x) >> 4) & 0xf)
  106. #define    lonibble(x)    ((x) & 0xf)
  107.  
  108. /* Various low-level and miscellaneous functions */
  109. unsigned long availmem __ARGS((void));
  110. void *callocw __ARGS((unsigned nelem,unsigned size));
  111. int dirps __ARGS((void));
  112. void freeargs __ARGS((int argc,char *argv[]));
  113. int getopt __ARGS((int argc,char *argv[],char *opts));
  114. int htoi __ARGS((char *));
  115. long htol __ARGS((char *));
  116. char *inbuf __ARGS((int16 port,char *buf,int16 cnt));
  117. void mainlog __ARGS((int s,char *fmt, ...));
  118. void *ltop __ARGS((long));
  119. void *mallocw __ARGS((unsigned nb));
  120. char *outbuf __ARGS((int16 port,char *buf,int16 cnt));
  121. long ptol __ARGS((void *));
  122. void restore __ARGS((int));
  123. void rip __ARGS((char *));
  124. char *smsg __ARGS((char *msgs[],unsigned nmsgs,unsigned n));
  125. int tprintf __ARGS((char *fmt,...));
  126. #if    !defined __TURBOC__
  127. char *strdup __ARGS((const char *));
  128. #endif
  129. int wildmat __ARGS((char *s,char *p,char **argv));
  130.  
  131. #include <stdlib.h>
  132. #include <string.h>
  133.  
  134. #ifdef    AZTEC
  135. #define    rewind(fp)    fseek(fp,0L,0);
  136. #endif
  137.  
  138. #ifdef    __TURBOC__
  139. #define movblock(so,ss,do,ds,c)    movedata(ss,so,ds,do,c)
  140. #define outportw outport
  141. #define inportw inport
  142.  
  143. #else
  144.  
  145. /* General purpose function macros already defined in turbo C */
  146. #ifndef    min
  147. #define    min(x,y)    ((x)<(y)?(x):(y))    /* Lesser of two args */
  148. #endif
  149. #ifndef max
  150. #define    max(x,y)    ((x)>(y)?(x):(y))    /* Greater of two args */
  151. #endif
  152. #ifdef    MSDOS
  153. #define MK_FP(seg,ofs)    ((void far *) \
  154.                (((unsigned long)(seg) << 16) | (unsigned)(ofs)))
  155. #endif
  156. #endif    /* __TURBOC __ */
  157.  
  158. #ifdef    AMIGA
  159. /* super kludge de WA3YMH */
  160. #ifndef    fileno
  161. #include <stdio.h>
  162. #endif
  163. #define fclose(fp)    amiga_fclose(fp)
  164. extern int amiga_fclose __ARGS((FILE *));
  165. extern FILE *tmpfile __ARGS((void));
  166.  
  167. extern char *sys_errlist[];
  168. extern int errno;
  169. #endif
  170.  
  171. /* Externals used by getopt */
  172. extern int optind;
  173. extern char *optarg;
  174.  
  175. /* Threshold setting on available memory */
  176. extern int32 Memthresh;
  177.  
  178. /* System clock - count of ticks since startup */
  179. extern int32 Clock;
  180.  
  181. /* Various useful standard error messages */
  182. extern char Badhost[];
  183. extern char Badinterface[];
  184. extern char Nospace[];
  185. extern char Notval[];
  186. extern char *Hostname;
  187. extern char Version[];
  188. extern char Mversion[];
  189. extern char Aversion[];
  190.  
  191. #endif    /* MAXINT16 */
  192.  
  193. #define    LINELEN        256
  194. #define    SLINELEN    64
  195.